package com.caigou.controller;


import com.caigou.bean.cms.entity.Copyright;
import com.caigou.bean.cms.entity.Us;
import com.caigou.bean.cms.param.CopyrightParam;
import com.caigou.bean.exam.entity.Users;
import com.caigou.enums.ResponseEnum;
import com.caigou.security.utils.CurrentUser;
import com.caigou.service.CopyrightService;
import com.caigou.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/copyright/")
public class CopyrightController {

    @Resource
    private CopyrightService copyrightService;

    @RequestMapping("listCopyright")
    @PreAuthorize("hasAnyAuthority('banquanxiangguan')")
    public Result listUs(@CurrentUser Users user){
        List<Copyright> copyrightList = copyrightService.listCopyright();
        return Result.success(copyrightList);
    }

    @RequestMapping("saveAndPublishCopyrightStatement")
    @PreAuthorize("hasAnyAuthority('banquanxiangguan')")
    public Result saveAndPublishCopyrightStatement(@RequestBody CopyrightParam param, Users user){
        return copyrightService.saveAndPublishCopyrightStatement(param);
    }

    @RequestMapping("updateTortImage")
    @PreAuthorize("hasAnyAuthority('banquanxiangguan')")
    public Result updateTortImage(@RequestBody CopyrightParam param, Users user){
        return copyrightService.updateTortImage(param);
    }

    @RequestMapping("saveAndPublishTortAnnouncement")
    @PreAuthorize("hasAnyAuthority('banquanxiangguan')")
    public Result saveAndPublishTortAnnouncement(@RequestBody CopyrightParam param, Users user){
        return copyrightService.saveAndPublishTortAnnouncement(param);
    }

}
